<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/3/20 0020
 * Time: 22:57
 */

namespace Lib;


use Lib\Core\Http;
use Lib\Core\WebSocket\WebSocket;

class App
{
    public function run($argv)
    {
        define('ROOT_PATH', dirname(dirname(__DIR__)));
        define('FRAME_PATH', ROOT_PATH . '/Framework');
        define('APP_PATH', ROOT_PATH . '/Application');
        define('CONFIG_PATH', APP_PATH . '/Config');
        try {
            switch ($argv[1]) {
                case 'start':
                    $http_server = new Http();
                    $http_server->run();
                    break;
                case 'ws:start':
                    try {
                        $wsServer = new WebSocket();
                        $wsServer->run();
                    } catch (\Throwable $throwable) {
                        var_dump($throwable->getMessage());
                    }

            }
        } catch (\Exception $exception) {
            echo $exception->getMessage() . PHP_EOL;
        } catch (\Throwable $throwable) {
        }

    }
}